#!/usr/bin/env python
#
# CUBudget: http://code.google.com/p/cubudget
#
# Copyright (c) 2008 Clemson University
# Released under the GNU GPL, version 2.

import cubudget

class Interest_Compund (object):
   core = cubudget.Core()

   def __init__(self):
      self.balance = 0
      self.principal = 0
      self.annual = 0
      self.compound = 0
      self.year = 0
      self.after_time = 0
      self.totalBalance = 0

   # gets balance from the core then returns the current balance
   def getBalance(self, curAccount):
      print curAccount
      return self.core.getAccountBalance(curAccount)

   def interest_runner(self, account):
   #should go through each account and compute interest
      for eachAccount in account:

   # if interest == true  #checks if interest needs to be computed
         self.balance = self.core.getAccountBalance(eachAccount)
         # Can't calculate if no balance is found
         if(self.balance is not None):
            self.principal += self.balance
            if(self.compound != 0):
               self.after_time =  (1 + ( self.annual / self.compound))
               self.after_time.exp( self.year * self.time)
               self.after_time = self.principal * self.after_time
            else:
               self.after_time = principal

      return self.after_time
